<?php
namespace app\admin\controller;

use app\admin\model\Teacher;
use app\BaseController;
use think\facade\Db;
use think\facade\Session;
use think\facade\View;

class User extends BaseController
{
    public function index()
    {
        $teacher = new Teacher();

//        if( !$this->request->isAjax() ){
//            return View::fetch();
//        }

        $username = $this->request->param('username');
        $password = $this->request->param('password');
        var_dump(md5($password));
        $name = $teacher->where(['username' => $username])->find();
        var_dump($name['password']);
        if( !$name ){
            if( !$name || md5($password) ){
                return json(['code'=>0,'msg'=>'用户名或密码错误']);
            }
            return json(['code'=>0,'msg'=>'用户名不存在']);
        }else{
            return json(['code'=>1,'msg'=>'登陆成功']);
        }
    }

    public function user(){
        echo md5('123456');
    }
}